//
// Created by Administrator on 2023/11/24.
//
#include "bits/stdc++.h"

using namespace std;

int main() {
    string Line;
    cin >> Line;
    vector<int> num;
    int first = 0;
    for (auto &s: Line) {
        if (isdigit(s)) {
            num.push_back(s - '0');
            if (!first) first = 1;//第一位标记
        } else {
            if (first) {//字符串为空
                break;
            }
        }
    }//单独分离保存到数组，然后后计算
    // 单独计算的原因是判断是否越界
    long long res = 0;
    for (auto &c: num) {
        res = res * 10 + c;
    }
    if (res > INT_MAX || !first) puts("-1");
    else cout << res << endl;
}


